package com.hdoit.apollo.logical.stock.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.stock.dao.IStockDao;
import com.hdoit.apollo.logical.stock.mapper.StockMapper;
import com.hdoit.apollo.logical.stock.model.Stock;
import com.hdoit.apollo.logical.stock.model.StockStat;
import com.hdoit.apollo.logical.viewmodel.stock.StockInfo;
import com.hdoit.apollo.logical.viewmodel.stock.StockSearch;
import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.message.PagerModel;
import com.tennetcn.data.utils.SqlExpressionFactory;
/**
 * @author      humaoshu
 * @email       
 * @createtime  2018年04月02日 11:35:58
 * @comment
 */
@Component
public class StockDaoImpl extends SuperDao<Stock> implements IStockDao{

	@Autowired
	private StockMapper stockMapper;
	@Override
	public Stock queryModelByKey(String cargoId) {
		return stockMapper.queryModelByKey(cargoId);
	}
	@Override
	public StockStat getStockStat(StockSearch search) {
		return stockMapper.getStockStat(search);
	}
	@Override
	public Stock getStockByCargoNo(String cargoNo, String shopId) {
		return stockMapper.getStockByCargoNo(cargoNo,shopId);
	}
	@Override

	public Stock queryModelByCargoId(String cargoId) {
		
		return stockMapper.queryModelByCargoId(cargoId);
		}

	public Stock getStockByCargoId(String cargoId, String shopId) {
		return stockMapper.getStockByCargoId(cargoId,shopId);

	}
	@Override
	public Stock queryModelByStockId(String stockId) {
		return stockMapper.queryModelByStockId(stockId);
	}
	@Override
	public List<Stock> queryListList(StockSearch search, PagerModel pagerModel) {
		return stockMapper.queryListList(search,pagerModel);
	}
	@Override
	public int queryCountList(StockSearch search) {
		return stockMapper.queryCountList(search);
	}
	@Override
	public List<StockInfo> getListBysearch(StockSearch search) {
		return stockMapper.getListBysearch(search);
	}
	@Override
	public boolean deleteByCargoId(String cargoId) {
		ISqlExpression sqlExpression = SqlExpressionFactory.createExpression();
		sqlExpression.addBody("delete from",Stock.class)
					.andWhere("cargoId=#{cargoId}")
					.setParam("cargoId", cargoId);
		return delete(sqlExpression)>=0;
	}
	@Override
	public List<StockInfo> getSupplierStocksBysearch(StockSearch search) {
		return stockMapper.getSupplierStocksBysearch(search);
	}

}
